//
//  NRWInputInfoCell.m
//  NRWMall
//
//  Created by 张记 on 2018/5/25.
//  Copyright © 2018年 com.anpxd. All rights reserved.
//

#import "NRWInputInfoCell.h"

@interface NRWInputInfoCell ()
@property (nonatomic, strong) UILabel *mainTitle;

@property (nonatomic, strong) UIButton *rightB;
@end

@implementation NRWInputInfoCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.separatorInset = UIEdgeInsetsZero;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self setupUI];

    }
    return self;
}
-(void)setupUI{
    
    self.mainTitle = DPLabel().setFont([UIFont systemFontOfSize:14]).setTextColor(mainFontColor());
    self.inputF = DPTextField().setTextColor(mainFontColor()).setFont([UIFont systemFontOfSize:14]).setTintColor(mainColor());
    self.inputF.textAlignment = NSTextAlignmentRight;
    self.inputF.keyboardType = UIKeyboardTypeDecimalPad;
    self.inputF.textColor = mainColor();
    self.rightB = DPButton().setTitleFont([UIFont systemFontOfSize:13]).setNormalTitleColor(mainFontColor());
    self.rightB.userInteractionEnabled = NO;
    self.contentView.addSubview(self.mainTitle).addSubview(self.inputF).addSubview(self.rightB);
    kSelfWeak;
    [weakSelf.mainTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView).mas_offset(16);
        make.centerY.equalTo(weakSelf.contentView);
    }];
    [weakSelf.rightB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(weakSelf.contentView).mas_offset(-16);
        make.centerY.equalTo(weakSelf.contentView);
        
    }];
    [weakSelf.inputF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView).mas_offset(90);
        make.right.equalTo(weakSelf.contentView).mas_offset(-60);
        make.height.equalTo(weakSelf.contentView);
        make.centerY.equalTo(weakSelf.contentView);
    }];
    
    
    
    
}
-(void)setIndex:(NSIndexPath *)index{
    _index = index;
    NSArray *titles = @[@"品牌车系",@"上牌时间",@"行驶里程",@"牌照所在地"];
    self.mainTitle.text = titles[index.row];
    NSArray *holders = @[@"请选择品牌车系",@"请选择首次上牌时间",@"请填写行驶里程",@"请选择牌照所在城市"];
    self.inputF.placeholder = holders[index.row];
    if (index.row == 2) {
        [self.rightB setTitle:@"万公里" forState:UIControlStateNormal];
        [self.rightB setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
        self.inputF.userInteractionEnabled = YES;
    }else{
        [self.rightB setTitle:@"" forState:UIControlStateNormal];
        [self.rightB setImage:[UIImage imageNamed:@"right"] forState:UIControlStateNormal];
        self.inputF.userInteractionEnabled = NO;

    }
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
